Modern microprocessors may perform numerous functions requiring a change of context state. For example, a microprocessor may change context state information when switching between groups of instructions, such as software threads. In changing between software threads, for example, context state of one group of instructions may be saved to a memory location and the context state of another group of instructions may be restored from memory and loaded into the microprocessor.
In reference to software threads, “context state” may refer to a portion of each software thread's state that is to be maintained between context switches within a processor. Context state may be stored in processor architectural registers, control registers, or other storage areas, such as memory. Context state is typically represented by a number of bits, the values of which define a particular context state.
The term “context switch” typically refers to a change from one processor execution state to another, such as a software thread switch. A context switch is typically performed either by the operating system or by a user's program. For example, a context switch may occur as a result of calling a subroutine within a user's program, in which the calling program's context is saved in a storage area when the call to the subroutine occurs, and restored from the storage area when returning from the called subroutine.